package a;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/ServletRequestDemo4")
public class ServletRequestDemo4 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取请求中的请求参数
        //get参数跟在连接后面
        //post出现在请求体中
        String username = request.getParameter("username");
        System.out.println("username:"+username);
        response.getWriter().write(username+"\n");
        String password = request.getParameter("password");
        System.out.println("password:"+password);
        response.getWriter().write(password);
    }
}
